import React, { PureComponent } from 'react'

export class App extends PureComponent {
  constructor() {
    super()
    this.state = {
      username: '',
      password: ''
    }
  }
  handleChangeInput(e) {
    this.setState({ [e.target.name]: e.target.value })
  }
  handleSubmit() {
    const { username, password } = this.state
    console.log(username, password)
  }
  render() {
    const { username, password } = this.state
    return (
      <div>
        <input type="text" name="username" value={username} onChange={e => this.handleChangeInput(e)} />
        <input type="password" name="password" value={password} onChange={e => this.handleChangeInput(e)} />
        <button onClick={() => this.handleSubmit()}>提交</button>
      </div>
    )
  }
}

export default App